<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <!-- <meta name="viewport" content="width=device-width, initial-scale=1.0" /> -->
    <title>Document</title>
    <style>
      .box {
        width: 100px;
        height: 100px;
        background-color: red;
      }
    </style>
  </head>
  <body>
    <!-- 1. touchstart并不能代替click事件. 建议实际开发还是使用click事件 -->

    <!-- 2. touchstart和click的触发时间间隔多久
        开启理想视口: 间隔约100ms左右
        不开启理想视口: 间隔约300ms左右
    -->
    <div class="box" id="box"></div>
    <script>
      let start
      box.ontouchstart = function () {
        start = Date.now()
        console.log('touchstart触发了')
      }
      box.onclick = function () {
        let end = Date.now()
        console.log('click触发了', end - start)
      }
    </script>
  </body>
</html>
